﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BillingSystem
{
    public partial class FormReport : Form
    {
        DataGridViewTextBoxColumn cONNECTIONDATEDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        DataGridViewTextBoxColumn tARGETPREFIXDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        DataGridViewTextBoxColumn tARGETNUMBERDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        DataGridViewTextBoxColumn dURATIONDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        DataGridViewTextBoxColumn cOSTDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        DataGridViewTextBoxColumn NUMBERDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        BindingSource cONNECTIONSBindingSource;

        DataGridViewTextBoxColumn OPERATION_DATEDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        DataGridViewTextBoxColumn AMOUNTDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
        BindingSource operationsBindingSource;

        public FormReport()
        {
            InitializeComponent();
        }

        private void InitGridConnections(BindingSource bs)
        {
            cONNECTIONSBindingSource = bs;

            // 
            // cONNECTIONDATEDataGridViewTextBoxColumn
            // 
            cONNECTIONDATEDataGridViewTextBoxColumn.DataPropertyName = "CONNECTION_DATE";
            cONNECTIONDATEDataGridViewTextBoxColumn.HeaderText = "Дата";
            cONNECTIONDATEDataGridViewTextBoxColumn.Name = "cONNECTIONDATEDataGridViewTextBoxColumn";
            cONNECTIONDATEDataGridViewTextBoxColumn.ReadOnly = true;
            // 
            // tARGETPREFIXDataGridViewTextBoxColumn
            // 
            tARGETPREFIXDataGridViewTextBoxColumn.DataPropertyName = "TARGET_PREFIX";
            tARGETPREFIXDataGridViewTextBoxColumn.HeaderText = "Код";
            tARGETPREFIXDataGridViewTextBoxColumn.Name = "tARGETPREFIXDataGridViewTextBoxColumn";
            tARGETPREFIXDataGridViewTextBoxColumn.ReadOnly = true;
            // 
            // tARGETNUMBERDataGridViewTextBoxColumn
            // 
            tARGETNUMBERDataGridViewTextBoxColumn.DataPropertyName = "TARGET_NUMBER";
            tARGETNUMBERDataGridViewTextBoxColumn.HeaderText = "Номер назначения";
            tARGETNUMBERDataGridViewTextBoxColumn.Name = "tARGETNUMBERDataGridViewTextBoxColumn";
            tARGETNUMBERDataGridViewTextBoxColumn.ReadOnly = true;
            // 
            // dURATIONDataGridViewTextBoxColumn
            // 
            dURATIONDataGridViewTextBoxColumn.DataPropertyName = "DURATION";
            dURATIONDataGridViewTextBoxColumn.HeaderText = "Длительность";
            dURATIONDataGridViewTextBoxColumn.Name = "dURATIONDataGridViewTextBoxColumn";
            dURATIONDataGridViewTextBoxColumn.ReadOnly = true;
            // 
            // cOSTDataGridViewTextBoxColumn
            // 
            cOSTDataGridViewTextBoxColumn.DataPropertyName = "COST";
            cOSTDataGridViewTextBoxColumn.HeaderText = "Стоимость";
            cOSTDataGridViewTextBoxColumn.Name = "cOSTDataGridViewTextBoxColumn";
            cOSTDataGridViewTextBoxColumn.ReadOnly = true;
            // 
            // cOSTDataGridViewTextBoxColumn
            // 
            NUMBERDataGridViewTextBoxColumn.DataPropertyName = "NUM";
            NUMBERDataGridViewTextBoxColumn.HeaderText = "Номер";
            NUMBERDataGridViewTextBoxColumn.Name = "NUMBERDataGridViewTextBoxColumn";
            NUMBERDataGridViewTextBoxColumn.ReadOnly = true;

            dataGridView1.MultiSelect = false;
            dataGridView1.ReadOnly = true;
            dataGridView1.RowHeadersVisible = false;
            dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.AllowUserToDeleteRows = false;
            dataGridView1.AllowUserToResizeRows = false;
            dataGridView1.AutoGenerateColumns = false;
            
            dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             NUMBERDataGridViewTextBoxColumn,
             cONNECTIONDATEDataGridViewTextBoxColumn,
             tARGETPREFIXDataGridViewTextBoxColumn,
             tARGETNUMBERDataGridViewTextBoxColumn,
             dURATIONDataGridViewTextBoxColumn,
             cOSTDataGridViewTextBoxColumn});
            dataGridView1.DataSource = cONNECTIONSBindingSource;
            dataGridView1.AutoResizeColumns();
        }

        private void InitGridOperations(BindingSource bs)
        {
            operationsBindingSource = bs;

            // 
            // cONNECTIONDATEDataGridViewTextBoxColumn
            // 
            OPERATION_DATEDataGridViewTextBoxColumn.DataPropertyName = "OPERATION_DATE";
            OPERATION_DATEDataGridViewTextBoxColumn.HeaderText = "Дата";
            OPERATION_DATEDataGridViewTextBoxColumn.Name = "OPERATION_DATEDataGridViewTextBoxColumn";
            OPERATION_DATEDataGridViewTextBoxColumn.ReadOnly = true;
            // 
            // cOSTDataGridViewTextBoxColumn
            // 
            AMOUNTDataGridViewTextBoxColumn.DataPropertyName = "AMOUNT";
            AMOUNTDataGridViewTextBoxColumn.HeaderText = "Сумма";
            AMOUNTDataGridViewTextBoxColumn.Name = "AMOUNTDataGridViewTextBoxColumn";
            AMOUNTDataGridViewTextBoxColumn.ReadOnly = true;

            dataGridView2.MultiSelect = false;
            dataGridView2.ReadOnly = true;
            dataGridView2.RowHeadersVisible = false;
            dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            dataGridView2.AllowUserToAddRows = false;
            dataGridView2.AllowUserToDeleteRows = false;
            dataGridView2.AllowUserToResizeRows = false;
            dataGridView2.AutoGenerateColumns = false;
            dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             AMOUNTDataGridViewTextBoxColumn,
             OPERATION_DATEDataGridViewTextBoxColumn});
            dataGridView2.DataSource = operationsBindingSource;
            dataGridView2.AutoResizeColumns();

        }


        public bool ShowForm(BindingSource bs_connections, BindingSource bs_operations, DataRowView client)
        {
            InitGridConnections(bs_connections);
            InitGridOperations(bs_operations);
                
            label3.Text = ((decimal)client["ACCOUNT_NUMBER"]).ToString();
            label5.Text = (client["FIO"]).ToString();
            
            if (ShowDialog() == DialogResult.OK)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
